package com.suxii.netty_demo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.suxii.Thread.NettyThread;
import com.suxii.pojo.ChatMsg;
import com.suxii.service.MyNettyService;

public class MainActivity extends AppCompatActivity {
    private EditText text;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        text = findViewById(R.id.text);

        Intent intent=new Intent(this,MyNettyService.class);
        startService(intent);

    }

    public void send(View view) {
        //Toast.makeText(this, text.getText(), Toast.LENGTH_SHORT).show();
        NettyThread.channel.writeAndFlush(new ChatMsg("tom",123,text.getText().toString(),222));
    }
}